using Microsoft.AspNetCore.Mvc;
using Process.Application.Department;
using Process.Domain.DTO.InputDTO;
using Process.Domain.DTO.OutDTO;
using Process.Result;
using System.Collections.Generic;

namespace Process.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class DepartmentController : ControllerBase
    {
        private readonly IDepartmentService _departmentService;

        public DepartmentController(IDepartmentService departmentService)
        {
            _departmentService = departmentService;
        }

        /// <summary>
        /// 获取所有部门信息
        /// </summary>
        /// <returns>部门列表</returns>
        [HttpGet]
        public ApiResult<List<PagingDepartmentDTO>> GetAll()
        {
            return _departmentService.GetAllDepartments();
        }

        /// <summary>
        /// 根据ID获取部门
        /// </summary>
        /// <param name="id">部门ID</param>
        /// <returns>部门信息</returns>
        [HttpGet]
        public ApiResult<PagingDepartmentDTO> GetById(long id)
        {
            return _departmentService.GetDepartmentById(id);
        }

        /// <summary>
        /// 分页查询部门
        /// </summary>
        /// <param name="input">分页及查询参数</param>
        /// <returns>分页部门数据</returns>
        [HttpGet]
        public Apipaging<PagingDepartmentDTO> PagingQuery([FromQuery] PagingDepartmentInput input)
        {
            return _departmentService.PagingDepartment(input);
        }

        [HttpGet]
        public ApiResult<List<ShowDepartmnetDTO>> ShowDepartments()
        {
            return _departmentService.ShowDepartments();
        }
        [HttpGet]
        public ApiResult<ShowDepartmnetDTO> GetById2(long id)
        {
            return _departmentService.GetDepartmentById2(id);
        }
    }
} 